<%@ page import="com.actimind.actitime.beans.UserBean,
                 com.actimind.actitime.Keys,
                 org.apache.struts.util.ResponseUtils,
                 com.actimind.actitime.beans.CustomerBean"%><%@ page errorPage="/error.jsp" %><%

UserBean loggedinUser = (UserBean)session.getAttribute(Keys.LOGGEDIN_USER_KEY);
CustomerBean customer = (CustomerBean)session.getAttribute(Keys.CUSTOMER_KEY);

if (loggedinUser == null)
{
    response.sendRedirect("../login.do");
}
else if (customer == null)
{
    response.sendRedirect("customerlist.do");
}
else
{
%>
<%@ taglib uri="/WEB-INF/at.tld" prefix="at" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<head>
    <title><bean:write name="title-prefix" scope="application"/> Edit Customer Information</title>

    <link rel="stylesheet" href="../css/at.css" type="text/css">

    <script language="JavaScript" src="../js/at.js"></script>
    <script language="JavaScript">
    function doSubmit(f)
    {
        /*if (!checkField(f.name, "Customer name is empty", "isNotEmpty"))
            return false;

        trimAllTextFields(f);
        normalizeAllTextFields(f);*/

        return true;
    }
    </script>
</head>

<body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">

<jsp:include page="../top.jsp" flush="false">
    <jsp:param name="pageSection" value="project" />
    <jsp:param name="pageAction" value="customeredit" />
</jsp:include>

<html:form scope="session" action="/project/customeredit.do" method="post" onsubmit="return doSubmit(this)">

<input type="hidden" name="submitted" value="1" />

<html:hidden property="customerId" />

<table cellspacing="0" cellpadding="5" align="center" valign="top" border="0" bgcolor="#ffffff" width="770">
<tr>
    <td class="pagetitle">
        Edit Customer Information
    </td>
</tr>
<tr>
    <td align="center" class="formbuttonpane">
        <table cellspacing="0" cellpadding="3" align="center" valign="top" border="0" width="100%">
        <tr>
            <td class="formblocktitle" width="23%" nowrap="1">
                You have selected customer:
            </td>
            <td class="formblocktitle">
                <span class="textemphasis"><%=ResponseUtils.filter(customer.getName())%></span>
            </td>
            <%
            if (customer.getProjectsNum() == 0)
            {
            %>
            <td rowspan="2" align="right" valign="top">
                <input type="button" value="Delete This Customer" onclick="javascript: if (confirm('Are you sure you want to delete this customer?')) document.location.href='<html:rewrite href='<%="customerdelete.do?customerId=" + customer.getId()%>'/>'" />
            </td>
            <%
            }
            %>
        </tr>
        <tr>
            <td class="formblocktitle" width="23%" nowrap="1">
                Customer creation date:
            </td>
            <td class="text">
                <span class="text"><%=customer.getCreationTimestamp("MMM dd, yyyy")%></span>
            </td>
        </tr>
        </table>
    </td>
</tr>
<tr>
    <td class="pagetitle">
        <at:errors />
        <at:messages id="message" message="true">
            <span class="successmsg"><bean:write name="message"/></span>
        </at:messages>
    </td>
</tr>
<tr>
    <td>
        <table cellspacing="0" cellpadding="0" align="left" valign="top" border="0" bgcolor="#ffffff">
        <tr>
            <td colspan="2" class="formcomment">
                <span class="formfieldtitlereq">*</span> Indicates a required field.
            </td>
        </tr>
        <tr>
            <td colspan="2"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        <tr>
            <td colspan="2" class="formblocktitle">
                Edit Customer Details
            </td>
        </tr>
        <tr>
            <td colspan="2"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        <tr>
            <td>
                <img height="1" width="20" src="../img/pixel.gif" />
            </td>
            <td>
                <table cellspacing="0" cellpadding="3" align="left" valign="top" border="0" bgcolor="#ffffff">
                <tr>
                    <td class="formfieldtitlereq">
                        *
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="name"><span class="errormsg">Customer Name:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="name">Customer Name:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:text property="name" style="width: 470px" maxlength="209" size="57"/>
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitlereqtop">
                        &nbsp;
                    </td>
                    <td class="formfieldtitletop">
                        <logic:messagesPresent property="billable"><span class="errormsg">Billing Status:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="billable">Billing Status:</logic:messagesNotPresent>
                    </td>
                    <td class="formfieldtitletop">
                        <html:radio property="billable" value="true">Billable</html:radio><br />
                        <html:radio property="billable" value="false">Non-Billable</html:radio>
                    </td>
                </tr>
                <tr>
                    <td class="formfieldtitlereqtop">
                        &nbsp;
                    </td>
                    <td class="formfieldtitletop">
                        <logic:messagesPresent property="description"><span class="errormsg">Customer Description:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="description">Customer Description:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:textarea property="description" style="width: 470px; height: 120px; " rows="7" cols="55"/>
                    </td>
                </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td colspan="2"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        </table>
    </td>
</tr>
<tr>
    <td align="center" class="formbuttonpane">
        <input type="submit" value="Save Changes" />
        <img height="1" width="100" src="../img/pixel.gif" />
        <input type="button" value="     Cancel     " onclick="if (confirm('Are you sure you want to cancel changing this customer?')) document.location.href='<html:rewrite href='customerlist.do'/>'" />
    </td>
</tr>
</table>

</html:form>

</body>
</html>
<%
}
%>